﻿using System;
using Glue;
using Xunit;

namespace GlueTests.AutoRelaterTests
{
    public class When_base_class_is_present
    {
        public class BaseClass
        {
            public String BaseClassProperty { get; set; }
            
        }

        public class SubClass : BaseClass
        {
            public String SubClassProperty { get; set; }
        }

        public class TheOtherBaseClass
        {
            public String BaseClassProperty { get; set; }
            public String SubClassProperty { get; set; }
        }

        public class TheOtherSubClass:TheOtherBaseClass {}

        [Fact]
        public void Should_get_all_public_properties_also_from_base_classes()
        {
            var mapping = new Mapping<SubClass, TheOtherSubClass>();
            mapping.AutoRelateEqualNames();
            Assert.Equal(2,mapping.Relations.Count);
        }

        [Fact]
        public void Should_get_all_public_properties_also_from_base_classes_reverse()
        {
            var mapping = new Mapping<TheOtherSubClass, SubClass>();
            mapping.AutoRelateEqualNames();
            Assert.Equal(2, mapping.Relations.Count);
        }
    }
}
